//
//  FindPasswordViewController.m
//  MarryMe
//
//  Created by lanou3g on 16/1/12.
//  Copyright © 2016年 revocher. All rights reserved.
//

#import "FindPasswordViewController.h"
#import <AVOSCloud.h>
@interface FindPasswordViewController ()
@property (strong, nonatomic) IBOutlet UITextField *phoneNumField;
@property (strong, nonatomic) IBOutlet UITextField *SecurityCodeField;


@property (strong, nonatomic) IBOutlet UITextField *PasswordField;

@end

@implementation FindPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)gettxtBtnClickedAction:(id)sender {
    [AVUser requestPasswordResetWithPhoneNumber:self.phoneNumField.text block:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            NSLog(@"验证码发送成功");
            
        }else{
            NSLog(@"%@",error);
        }
    }];



}


- (IBAction)newPasswordClickedAction:(id)sender {
    [AVUser resetPasswordWithSmsCode:self.SecurityCodeField.text newPassword:self.PasswordField.text block:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
            NSLog(@"重置成功");
        }else{
            NSLog(@"%@",error);
            UIAlertController * alertControlller = [UIAlertController alertControllerWithTitle:@"提示" message:@"重置失败,请重新输入" preferredStyle:    UIAlertControllerStyleAlert];
            UIAlertAction *  cancelAction = [UIAlertAction actionWithTitle:@"取消" style:  UIAlertActionStyleDefault  handler:nil];
            [alertControlller addAction: cancelAction];
            self.PasswordField.text = nil;
            [self.navigationController presentViewController:alertControlller animated:YES completion:nil];

        }
    }];

    
    
    
}




/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
